package com.limao.DBProvider;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;

import com.limao.DBDataClass.CrowdSysProjectCutClass;
import com.limao.DbConnection.DbConnectionManager;
import com.limao.Tool.CacheClass;

public class SysGoodsCutProvider {
	
	private static SysGoodsCutProvider instance=null;

	public static SysGoodsCutProvider getInstance() {
		if(instance==null)
		{
			instance=new SysGoodsCutProvider();
		}
		return instance;
	}
	
	// 初始化
	private SysGoodsCutProvider() {

	}
	
	public CrowdSysProjectCutClass RsToSysGoodsCutDataClass(ResultSet rs) throws SQLException
	{
		CrowdSysProjectCutClass tmp = new CrowdSysProjectCutClass();
		tmp = new CrowdSysProjectCutClass();
		
		tmp.projectid=rs.getString("projectid");
		tmp.regular=rs.getString("regular");
		tmp.regular_type=rs.getString("regular_type");
		tmp.buy_self_ornot=rs.getString("buy_self_ornot");
		
		tmp.redbag=rs.getString("redbag");
		tmp.buy_self_redbag=rs.getString("buy_self_redbag");
		
		tmp.regular_num0_0=rs.getString("regular_num0_0");
		tmp.regular_num1_0=rs.getString("regular_num1_0");
		tmp.regular_num2_0=rs.getString("regular_num2_0");
		tmp.regular_num3_0=rs.getString("regular_num3_0");
		tmp.regular_scale0_0=rs.getString("regular_scale0_0");
		tmp.regular_scale1_0=rs.getString("regular_scale1_0");
		tmp.regular_scale2_0=rs.getString("regular_scale2_0");
		tmp.regular_scale3_0=rs.getString("regular_scale3_0");
		tmp.redbagid0_0=rs.getString("redbagid0_0");
		tmp.redbagid1_0=rs.getString("redbagid1_0");
		tmp.redbagid2_0=rs.getString("redbagid2_0");
		tmp.redbagid3_0=rs.getString("redbagid3_0");
		
		
		tmp.regular_num0_1=rs.getString("regular_num0_1");
		tmp.regular_num1_1=rs.getString("regular_num1_1");
		tmp.regular_num2_1=rs.getString("regular_num2_1");
		tmp.regular_num3_1=rs.getString("regular_num3_1");
		tmp.regular_scale0_1=rs.getString("regular_scale0_1");
		tmp.regular_scale1_1=rs.getString("regular_scale1_1");
		tmp.regular_scale2_1=rs.getString("regular_scale2_1");
		tmp.regular_scale3_1=rs.getString("regular_scale3_1");
		tmp.redbagid0_1=rs.getString("redbagid0_1");
		tmp.redbagid1_1=rs.getString("redbagid1_1");
		tmp.redbagid2_1=rs.getString("redbagid2_1");
		tmp.redbagid3_1=rs.getString("redbagid3_1");
		
		tmp.regular_num0_2=rs.getString("regular_num0_2");
		tmp.regular_num1_2=rs.getString("regular_num1_2");
		tmp.regular_num2_2=rs.getString("regular_num2_2");
		tmp.regular_num3_2=rs.getString("regular_num3_2");
		tmp.regular_scale0_2=rs.getString("regular_scale0_2");
		tmp.regular_scale1_2=rs.getString("regular_scale1_2");
		tmp.regular_scale2_2=rs.getString("regular_scale2_2");
		tmp.regular_scale3_2=rs.getString("regular_scale3_2");
		tmp.redbagid0_2=rs.getString("redbagid0_2");
		tmp.redbagid1_2=rs.getString("redbagid1_2");
		tmp.redbagid2_2=rs.getString("redbagid2_2");
		tmp.redbagid3_2=rs.getString("redbagid3_2");
		
		tmp.regular_num0_3=rs.getString("regular_num0_3");
		tmp.regular_num1_3=rs.getString("regular_num1_3");
		tmp.regular_num2_3=rs.getString("regular_num2_3");
		tmp.regular_num3_3=rs.getString("regular_num3_3");
		tmp.regular_scale0_3=rs.getString("regular_scale0_3");
		tmp.regular_scale1_3=rs.getString("regular_scale1_3");
		tmp.regular_scale2_3=rs.getString("regular_scale2_3");
		tmp.regular_scale3_3=rs.getString("regular_scale3_3");
		tmp.redbagid0_3=rs.getString("redbagid0_3");
		tmp.redbagid1_3=rs.getString("redbagid1_3");
		tmp.redbagid2_3=rs.getString("redbagid2_3");
		tmp.redbagid3_3=rs.getString("redbagid3_3");
		
		tmp.regular_num0_4=rs.getString("regular_num0_4");
		tmp.regular_num1_4=rs.getString("regular_num1_4");
		tmp.regular_num2_4=rs.getString("regular_num2_4");
		tmp.regular_num3_4=rs.getString("regular_num3_4");
		tmp.regular_scale0_4=rs.getString("regular_scale0_4");
		tmp.regular_scale1_4=rs.getString("regular_scale1_4");
		tmp.regular_scale2_4=rs.getString("regular_scale2_4");
		tmp.regular_scale3_4=rs.getString("regular_scale3_4");
		tmp.redbagid0_4=rs.getString("redbagid0_4");
		tmp.redbagid1_4=rs.getString("redbagid1_4");
		tmp.redbagid2_4=rs.getString("redbagid2_4");
		tmp.redbagid3_4=rs.getString("redbagid3_4");
		
		tmp.regular_num0_5=rs.getString("regular_num0_5");
		tmp.regular_num1_5=rs.getString("regular_num1_5");
		tmp.regular_num2_5=rs.getString("regular_num2_5");
		tmp.regular_num3_5=rs.getString("regular_num3_5");
		tmp.regular_scale0_5=rs.getString("regular_scale0_5");
		tmp.regular_scale1_5=rs.getString("regular_scale1_5");
		tmp.regular_scale2_5=rs.getString("regular_scale2_5");
		tmp.regular_scale3_5=rs.getString("regular_scale3_5");
		tmp.redbagid0_5=rs.getString("redbagid0_5");
		tmp.redbagid1_5=rs.getString("redbagid1_5");
		tmp.redbagid2_5=rs.getString("redbagid2_5");
		tmp.redbagid3_5=rs.getString("redbagid3_5");
		
		return tmp;
	}
	
	 public CrowdSysProjectCutClass loadGoodsCut(String packageid)
	 {
		 	CrowdSysProjectCutClass tmp = null;
			Connection con = null;
			PreparedStatement pstmt = null;
			ResultSet rs = null;
			try {

				con = DbConnectionManager.getConnection();
				pstmt = con.prepareStatement("select * from cd_sys_goodscut  where projectid=? ");
				pstmt.setInt(1, CacheClass.getIntValue(packageid));
				rs = pstmt.executeQuery();
				if (rs.next()) {
					
					tmp=RsToSysGoodsCutDataClass(rs);
				}
			} catch (Exception e) {
				tmp = null;
				e.printStackTrace();
			} finally {
				DbConnectionManager.closeConnection(rs, pstmt, con);
			}
			return tmp;
	 }
	 
	

}
